package com.baijiaxing.weixin.family.message.units;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

/**
 * 消息工具类
 * @author June
 *
 */
public class FamilyMessageUnits {

	/**
	 * <p>Title: getMsgType</p>
	 * <p>Description: 判断消息类型</p>
	 * @param msgXml
	 * @return
	 * @throws DocumentException 
	 */
	public static String getMsgType(String msgXml) throws DocumentException{
		Document doc = DocumentHelper.parseText(msgXml);
		Element root = doc.getRootElement();
		String msgType = root.element("MsgType").getStringValue();
		return msgType;
	}
	
	/**
	 * <p>Title: getMsgType</p>
	 * <p>Description: 判断事件类型</p>
	 * @param msgXml
	 * @return
	 * @throws DocumentException 
	 */
	public static String getEventType(String msgXml) throws DocumentException{
		Document doc = DocumentHelper.parseText(msgXml);
		Element root = doc.getRootElement();
		String msgType = root.element("Event").getStringValue();
		return msgType;
	}
}
